package jmine.tec.utils.collection.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import jmine.tec.utils.collection.MultiMap;

/**
 * Implementacao de {@link MultiMap} nao inserivel
 * 
 * @author takeshi
 * @param <K> o tipo da chave
 * @param <V> o tipo dos valores
 */
public class EmptyMultiMap<K, V> extends AbstractMultiMap<K, V> implements Cloneable, Serializable, MultiMap<K, V> {

    private static final EmptyMultiMap SHARED_INSTANCE = new EmptyMultiMap();

    /**
     * Devolve uma instancia compartilhada do EmptyMultiMap jah que ela eh vazia
     * 
     * @param <K> o tipo da chave
     * @param <V> o tipo do valor
     * @return {@link MultiMap}
     */
    @SuppressWarnings("unchecked")
    public static <K, V> MultiMap<K, V> getInstance() {
        return SHARED_INSTANCE;
    }

    private static final int SHARED_HASH_CODE = EmptyMultiMap.class.getName().hashCode();

    /**
     * {@inheritDoc}
     */
    @Override
    public int size() {
        return 0;
    }

    /**
     * {@inheritDoc}
     */
    public boolean containsKey(K key) {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public boolean add(K key, V value) {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public Collection<? extends V> get(K key) {
        return Collections.emptyList();
    }

    /**
     * {@inheritDoc}
     */
    public boolean remove(K key, V item) {
        return false;
    }

    /**
     * {@inheritDoc}
     */
    public Collection<? extends V> removeAll(K key) {
        return Collections.emptyList();
    }

    /**
     * {@inheritDoc}
     */
    public Map<K, Collection<V>> toPlainMap() {
        return new HashMap<K, Collection<V>>();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        return obj instanceof EmptyMultiMap;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return SHARED_HASH_CODE;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return "{}";
    }

}
